#ifndef _GRAFIKA_H
#define _GRAFIKA_H

#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <mem.h>
#include "BOOLEAN.H"

#define VGA_MODE	0x13
#define TEXT_MODE	0x03

#define SCREEN_WIDTH	320
#define SCREEN_HEIGHT	200
#define NUM_PIXELS		64000
#define NUM_COLORS		256

#define INPUT_STATUS_1	0x03da
#define VRETRACE		0x08
#define PALETTE_DATA    0x03c9
#define PALETTE_INDEX   0x03c8

#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define LIGHT_GRAY 7
#define DARK_GRAY 8
#define LIGHT_BLUE 9
#define LIGHT_GREEN 10
#define LIGHT_CYAN 11
#define LIGHT_RED 12
#define LIGHT_MAGENTA 13
#define YELLOW 14
#define WHITE 15

#define sgn(x) ((x<0)?-1:((x>0)?1:0))

#ifndef _BYTE_
#define _BYTE_
typedef unsigned char byte;
#endif

#ifndef _WORD_
#define _WORD_
typedef unsigned short word;
#endif

typedef struct
{
  word width;
  word height;
  byte palette[256*3];
  byte *data;
} BITMAP;

typedef struct              /* the structure for a button. */
{
  int x;
  int y;
  int state;
  int height;
  int width;
  int numState;
  byte* bitmap;
} BUTTON;

void drawButton(BUTTON *button, byte transparent);
void setMode(byte mode);
void setBackground(byte color);
void drawLine(int x0, int y0, int x1, int y1, byte color);
void drawRectangle(int left, int top, int right, int bottom, byte color);
void fillRectangle(int left, int top, int right, int bottom, byte color);
void drawCircle(int x, int y, int radius, byte color);
void fillCircle(int x, int y, int radius, byte color);
void redraw(void);
byte getPixel(int x, int y);
void putPixel(int x, int y, byte color);
boolean loadBMP(const char *file, BITMAP* b);
void setPalette(byte* palette);
void drawBitmap(BITMAP* bmp,int x,int y);
void drawTransparentBitmap(BITMAP* bmp,int x,int y, byte background);
#endif
